package cn.ylg.com.ontouchdemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;

/**
 * Created by MyPC on 2016/10/17.
 */
public class OnTouchActivity extends Activity implements View.OnTouchListener {
    private Button button;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ontouch);
        button = (Button) findViewById(R.id.btn);
        /* 如果一直按触发onLongActivity 松开onClick  */
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Cutils.d("------OnClick");
                Intent intent = new Intent(OnTouchActivity.this,TransaltingActivity.class);
                startActivity(intent);
            }
        });
        button.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                Cutils.d("------OnLongClick");
                return false;
            }
        });
        button.setOnTouchListener(this);
    }

    //比点击事件还要优先;onTouch是一直触发的;
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        int x = (int) event.getX();
        int y = (int) event.getY();
        Cutils.d("------onTouch");
        switch (event.getAction()){
            case MotionEvent.ACTION_DOWN:
                break;
            case MotionEvent.ACTION_MOVE:
                break;
            case MotionEvent.ACTION_UP:
                break;
        }
        return false;
    }
}
